#include "ParsedData.h"

namespace parser {

// ParserData

ParsedData* ParsedData::addWarning(std::string warningMsg) {
	this->warnings.append(warningMsg);
	return this;
}

std::string ParsedData::getNextWarning() {
	return this->warnings.removeFirst();
}

bool ParsedData::hasWarnings() {
	return !this->warnings.isEmpty();
}

// VertexParserData

VertexParsedData::VertexParsedData() {
	this->setX(0.0);
	this->setY(0.0);
}

VertexParsedData::~VertexParsedData() {

}

// getters
double VertexParsedData::getX() {
	return this->x;
}

double VertexParsedData::getY() {
	return this->y;
}

std::string VertexParsedData::getId() {
	return this->id;
}

// setters
VertexParsedData* VertexParsedData::setX(double x) {
	this->x = x;
	return this;
}

VertexParsedData* VertexParsedData::setY(double y) {
	this->y = y;
	return this;
}

VertexParsedData* VertexParsedData::setId(std::string id)
		throw (InvalidDataException) {
	if (id != "") {
		this->id = id;
		return this;
	} else {
		throw(InvalidDataException("El id no puede ser vacio."));
	}
}

// EdgeParserData

EdgeParsedData::EdgeParsedData() {
	this->setLength(100.0);
	this->setMaxSpeed(60.0);
}

EdgeParsedData::~EdgeParsedData() {

}
// getters
std::string EdgeParsedData::getId() {
	return this->id;
}

double EdgeParsedData::getLength() {
	return this->length;
}

double EdgeParsedData::getMaxSpeed() {
	return this->maxSpeed;
}

std::string EdgeParsedData::getIdO() {
	return this->idO;
}

std::string EdgeParsedData::getIdD() {
	return this->idD;
}

// setters
EdgeParsedData* EdgeParsedData::setId(std::string id)
		throw (InvalidDataException) {
	if (id != "") {
		this->id = id;
		return this;
	} else {
		throw(InvalidDataException("El id no puede ser vacio."));
	}
}

EdgeParsedData* EdgeParsedData::setLength(double length) {
	this->length = length;
	return this;
}

EdgeParsedData* EdgeParsedData::setMaxSpeed(double maxSpeed)
		throw (InvalidDataException) {
	if (maxSpeed > 0.0) {
		this->maxSpeed = maxSpeed;
		return this;
	} else {
		throw(InvalidDataException(
				"La velocidad de una arista debe ser mayor a cero."));
	}
}

EdgeParsedData* EdgeParsedData::setIdO(std::string idO)
		throw (InvalidDataException) {
	if (idO != "") {
		this->idO = idO;
		return this;
	} else {
		throw(InvalidDataException("El id no puede ser vacio."));
	}
}

EdgeParsedData* EdgeParsedData::setIdD(std::string idD)
		throw (InvalidDataException) {
	if (idD != "") {
		this->idD = idD;
		return this;
	} else {
		throw(InvalidDataException("El id no puede ser vacio."));
	}
}

} // end of namespace
